home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PACKET / CBBS60SO.ZIP / MBSUBS.ASM < prev    next >
Assembly Source File  |  1987-09-29  |  2KB  |  102 lines

  1.  page    60,132
  2. ; BRK.ASM   3/25/87
  3. ; by David Toth, VE3GYQ, Modified by W0RLI
  4. ;
  5. ; These are C callable routines, called by
  6. ; brkoff()  --    to set ctrl-brk interrupt (1BH) and ctrl-c interrupt (23H)
  7. ;        so that it is ignored and execution continues.
  8. ; brkon()   --    resets ctrl-brk to its normal action.
  9.  
  10. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  11.  
  12.     assume    cs:_text
  13.  
  14.     PUBLIC    _brkoff,_brkon
  15.  
  16. eswd    dw    ?
  17. bxwd    dw    ?
  18.  
  19. _brkoff     proc near
  20.  
  21.         push bp
  22.         mov bp,sp
  23.         push ds
  24.         push di
  25.         push si
  26.  
  27.         mov ax,351bh       ; get ctl_brk interrupt vector
  28.         int 21h           ; vector returned in ES:BX
  29.         mov cs:bxwd,bx
  30.         mov cs:eswd,bx     ; save the old vector to return later
  31.  
  32.         push cs           ; the data segment
  33.         pop  ds
  34.  
  35.         mov dx,offset do_ti
  36.         mov ax,251bh       ;  set interrupt vector
  37.         int 21h           ; ctrl-brk routine is now at do_ti
  38.  
  39.         mov dx,offset do_it
  40.         mov ax,2523h       ; set interrupt vector
  41.         int 21h           ; ctrl-c routine is now at do_it
  42.  
  43.         pop  si
  44.         pop  di
  45.         pop  ds
  46.         pop  bp
  47.  
  48.         ret
  49. _brkoff     endp
  50.  
  51. ; Control-C interrupt handler.
  52.  
  53. do_it        proc far
  54.         clc            ;zero the carry flag which
  55.         ret            ;allows program to continue execution
  56. do_it        endp
  57.  
  58. ; Control-break interrupt handler.
  59.  
  60. do_ti        proc far
  61.         iret           ;allows program to continue execution
  62. do_ti        endp
  63.  
  64. _brkon        proc near
  65.  
  66.         push bp
  67.         mov bp,sp
  68.         push ds
  69.         push di
  70.         push si
  71.  
  72.         mov ds,cs:eswd     ; put BX word back into DX
  73.         mov dx,cs:bxwd     ; put BX word back into DX
  74.         mov ax,251bh       ; set interrupt vector
  75.         int 21h           ; ctrl-brk is restored
  76.  
  77.         pop  si
  78.         pop  di
  79.         pop  ds
  80.         pop  bp
  81.  
  82.         ret
  83. _brkon        endp
  84.  
  85.  
  86. ; return status of keyboard without allowing CTRL-C to signal break.
  87.  
  88.  
  89.     PUBLIC    _kbstat
  90. _kbstat proc    near
  91.         mov    ah,1
  92.         int    16h
  93.         mov    ax,0
  94.         jz    nochar        ;zero means no character available
  95.         not    ax
  96. nochar:
  97.         ret
  98. _kbstat endp
  99.  
  100. _TEXT    ENDS
  101.         end
  102.